package zm.irc.cmd;
import org.apache.log4j.Logger;

import zm.irc.client.IrcClient;
import zm.irc.ioc.annotation.Service;
import zm.irc.message.processor.MqttProcessor;
import zm.irc.message.receive.IrcReceiveCmdMessage;


/**
 * <pre>
 * show the chat history of the query user in current channel
 * Useage : 'ch [page number] [page size]
 * page number: optional , default is 1
 * page size : optional , default is 30
 * </pre>
 */
@Service(name=CommandNameConst.CMD_MQTT_CHANNEL)
public class CmdMQTTChannel implements IrcChatMsgCmd{
    private static final Logger log = Logger.getLogger(CmdMQTTChannel.class);


  
    public CmdMQTTChannel(){
    }


    @Override
    public boolean execute(IrcReceiveCmdMessage cmd, IrcClient client) {
        String[]  params = cmd.getCmdParams();
        if( params == null || params.length != 2){
            log.warn("Param error!" + params);
            return true;
        }
        String operator = params[0];
        String channelName = params[1];
        if("add".equalsIgnoreCase(operator)){
            MqttProcessor.addTargetChannel(channelName);
        }else if("del".equalsIgnoreCase(operator)){
            MqttProcessor.delTargetChannel(channelName);
        }else{
            log.warn("Operator not supported" + params);
            return true;
        }

        return true;
    }



 
}
